
let trim = str => {
  return str.replace(/(^\s*)|(\s*$)/g, '')
}

let ltrim = str => {
  return str.replace(/(^\s*)/g, '')
}

let rtrim = str => {
  return str.replace(/(\s*$)/g, '')
}

// 从链接中获取参数
let getQueryStr = (name, str) => {
  var match = RegExp('[?&]' + name + '=([^&]*)').exec(str)
  return match && decodeURIComponent(match[1].replace(/\+/g, ' '))
}

module.exports = {
  trim,
  ltrim,
  rtrim,
  getQueryStr
}
